﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Core
{
    public partial class BestPupils : Form
    {
        public BestPupils()
        {
            InitializeComponent();
        }
        private SchoolClass sch = null;
        public int BestCount = 10;

        public void LoadBest(SchoolClass schclass,int count)
        {
            BestCount = count;
            sch = schclass;
            RetingManagement.Sort(ref schclass);
            RetingManagement.CompileBest(schclass, ref this.richTextBox1, count);
        }
        private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            sch = RetingManagement.ReadData(openFileDialog1.FileName);
            if (sch != null)
            {
                LoadBest(sch, BestCount);
            }
        }
        private void загрузитьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SetForm set = new SetForm();
            set.ShowDialog();
            if (set.GetCount() != 0)
            {
                BestCount = set.GetCount();
                set.Close();
                openFileDialog1.ShowDialog();
            }
        }
        private void сохранитьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            saveFileDialog1.ShowDialog();
        }
        private void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
           richTextBox1.SaveFile(saveFileDialog1.FileName);
        }
        private void закрытьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
